package com.ghsc.ghxc.jsb.ui.my.activity

import androidx.lifecycle.MutableLiveData
import com.cn.appcore.base.BaseViewModel
import com.cn.appcore.ext.executeResponse
import com.cn.appcore.http.bean.BaseResponse
import com.ghsc.ghxc.jsb.api.ApiMarket
import com.ghsc.ghxc.jsb.ui.my.bean.BackCartResult
import com.ghsc.ghxc.jsb.ui.my.bean.IntegralResultData
import com.ghsc.ghxc.jsb.ui.my.bean.SfzNoAreaResult
import com.ghsc.ghxc.jsb.ui.my.bean.UserResultDataBean
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext

/**
 * 项目：GuoHuaJsb
 * 包名：com.ghsc.ghxc.jsb.ui.my.activity
 * 类名：RealNameAuthViewModel
 * 创建时间：2024/4/24 20:04
 * 创建人 @author： xiaolin
 * 描述 ：Todo...
 */
class RealNameAuthViewModel : BaseViewModel() {



    /**
     * 个人中心
     */
    val onUserInfoData: MutableLiveData<BaseResponse<UserResultDataBean>> = MutableLiveData()
    fun onUserInfoMethod() {
        launch {
            val response = withContext(Dispatchers.IO) { ApiMarket.service.onUserInfoData() }
            executeResponse(
                response,
                { onUserInfoData.value = response },
                { againLoginMsg.value = response.msg }
            ) { errorMsg.value = response.msg }
        }

    }
    //银行卡列表
    val onBankCardListData: MutableLiveData<BaseResponse<BackCartResult>> = MutableLiveData()
    fun onBankCardListMethod() {
        launch {
            val response = withContext(Dispatchers.IO) { ApiMarket.service.onBankCardListData() }
            executeResponse(
                response,
                { onBankCardListData.value = response },
                { againLoginMsg.value = response.msg }
            ) { errorMsg.value = response.msg }
        }

    }

    //根据身份证获取归属地
    val onSfzAreaData: MutableLiveData<BaseResponse<SfzNoAreaResult>> = MutableLiveData()
    fun onSfzAreaMethod(paras: String) {
        launch {
            val response = withContext(Dispatchers.IO) { ApiMarket.service.onSfzAreaData(paras) }
            executeResponse(
                response,
                { onSfzAreaData.value = response},
                { againLoginMsg.value = response.msg}
            ) { errorMsg.value = response.msg }

        }
    }

    //实名认证
    val onRenZhengData: MutableLiveData<BaseResponse<Any>> = MutableLiveData()
    fun onRenZhengMethod(paras: String) {
        launch {
            val response = withContext(Dispatchers.IO) { ApiMarket.service.onRenZhengData(paras) }
            executeResponse(
                response,
                { onRenZhengData.value = response},
                { againLoginMsg.value = response.msg}
            ) { errorMsg.value = response.msg }

        }
    }


}